<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>googleapiclient.http.MediaFileUpload</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="googleapiclient-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="googleapiclient-module.html">Package&nbsp;googleapiclient</a> ::
        <a href="googleapiclient.http-module.html">Module&nbsp;http</a> ::
        Class&nbsp;MediaFileUpload
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="googleapiclient.http.MediaFileUpload-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class MediaFileUpload</h1><p class="nomargin-top"><span class="codelink"><a href="googleapiclient.http-pysrc.html#MediaFileUpload">source&nbsp;code</a></span></p>
<center>
<center>  <map id="uml_class_diagram_for_googleap_29" name="uml_class_diagram_for_googleap_29">
<area shape="rect" id="node1_11" href="googleapiclient.http.MediaFileUpload-class.html#__init__" title="Constructor." alt="" coords="17,297,596,316"/>
<area shape="rect" id="node1_12" href="googleapiclient.http.MediaFileUpload-class.html#to_json" title="Creating a JSON representation of an instance of MediaFileUpload." alt="" coords="17,316,596,335"/>
<area shape="rect" id="node1_13" href="googleapiclient.http.MediaFileUpload-class.html#from_json" title="googleapiclient.http.MediaFileUpload.from_json" alt="" coords="17,335,596,353"/>
<area shape="rect" id="node1" href="googleapiclient.http.MediaFileUpload-class.html" title="A MediaUpload for a file." alt="" coords="5,267,608,360"/>
<area shape="rect" id="node2_14" href="googleapiclient.http.MediaIoBaseUpload-class.html#chunksize" title="Chunk size for resumable uploads." alt="" coords="223,111,391,129"/>
<area shape="rect" id="node2_15" href="googleapiclient.http.MediaIoBaseUpload-class.html#mimetype" title="Mime type of the body." alt="" coords="223,129,391,148"/>
<area shape="rect" id="node2_16" href="googleapiclient.http.MediaIoBaseUpload-class.html#size" title="Size of upload." alt="" coords="223,148,391,167"/>
<area shape="rect" id="node2_17" href="googleapiclient.http.MediaIoBaseUpload-class.html#resumable" title="Whether this upload is resumable." alt="" coords="223,167,391,185"/>
<area shape="rect" id="node2_18" href="googleapiclient.http.MediaIoBaseUpload-class.html#getbytes" title="Get bytes from the media." alt="" coords="223,185,391,204"/>
<area shape="rect" id="node2_19" href="googleapiclient.http.MediaIoBaseUpload-class.html#has_stream" title="Does the underlying upload support a streaming interface." alt="" coords="223,204,391,223"/>
<area shape="rect" id="node2_20" href="googleapiclient.http.MediaIoBaseUpload-class.html#stream" title="A stream interface to the data being uploaded." alt="" coords="223,223,391,241"/>
<area shape="rect" id="node2" href="googleapiclient.http.MediaIoBaseUpload-class.html" title="A MediaUpload for a io.Base objects." alt="" coords="211,80,403,248"/>
<area shape="rect" id="node3_21" href="googleapiclient.http.MediaUpload-class.html#new_from_json" title="Utility class method to instantiate a MediaUpload subclass from a JSON representation produced by to_json()." alt="" coords="239,36,373,55"/>
<area shape="rect" id="node3" href="googleapiclient.http.MediaUpload-class.html" title="Describes a media object to upload." alt="" coords="226,5,385,61"/>
</map>
  <img src="uml_class_diagram_for_googleap_29.gif" alt='' usemap="#uml_class_diagram_for_googleap_29" ismap="ismap" class="graph-without-title" />
</center>
</center>
<hr />
<pre class="literalblock">
A MediaUpload for a file.

Construct a MediaFileUpload and pass as the media_body parameter of the
method. For example, if we had a service that allowed uploading images:


  media = MediaFileUpload('cow.png', mimetype='image/png',
    chunksize=1024*1024, resumable=True)
  farm.animals().insert(
      id='cow',
      name='cow.png',
      media_body=media).execute()

Depending on the platform you are working on, you may pass -1 as the
chunksize, which indicates that the entire file should be uploaded in a single
request. If the underlying platform supports streams, such as Python 2.6 or
later, then this can be very efficient as it avoids multiple connections, and
also avoids loading the entire file into memory before sending it. Note that
Google App Engine has a 5MB limit on request size, so you should never set
your chunksize larger than 5MB, or to -1.

</pre>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="googleapiclient.http.MediaFileUpload-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">filename</span>,
        <span class="summary-sig-arg">mimetype</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">chunksize</span>=<span class="summary-sig-default">DEFAULT_CHUNK_SIZE</span>,
        <span class="summary-sig-arg">resumable</span>=<span class="summary-sig-default">False</span>)</span><br />
      Constructor.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="googleapiclient.http-pysrc.html#MediaFileUpload.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="googleapiclient.http.MediaFileUpload-class.html#to_json" class="summary-sig-name">to_json</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Creating a JSON representation of an instance of MediaFileUpload.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="googleapiclient.http-pysrc.html#MediaFileUpload.to_json">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="googleapiclient.http.MediaIoBaseUpload-class.html">MediaIoBaseUpload</a></code></b>:
      <code><a href="googleapiclient.http.MediaIoBaseUpload-class.html#chunksize">chunksize</a></code>,
      <code><a href="googleapiclient.http.MediaIoBaseUpload-class.html#getbytes">getbytes</a></code>,
      <code><a href="googleapiclient.http.MediaIoBaseUpload-class.html#has_stream">has_stream</a></code>,
      <code><a href="googleapiclient.http.MediaIoBaseUpload-class.html#mimetype">mimetype</a></code>,
      <code><a href="googleapiclient.http.MediaIoBaseUpload-class.html#resumable">resumable</a></code>,
      <code><a href="googleapiclient.http.MediaIoBaseUpload-class.html#size">size</a></code>,
      <code><a href="googleapiclient.http.MediaIoBaseUpload-class.html#stream">stream</a></code>
      </p>
    <div class="private">    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="googleapiclient.http.MediaUpload-class.html">MediaUpload</a></code></b> (private):
      <code><a href="googleapiclient.http.MediaUpload-class.html#_to_json" onclick="show_private();">_to_json</a></code>
      </p></div>
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__delattr__</code>,
      <code>__format__</code>,
      <code>__getattribute__</code>,
      <code>__hash__</code>,
      <code>__new__</code>,
      <code>__reduce__</code>,
      <code>__reduce_ex__</code>,
      <code>__repr__</code>,
      <code>__setattr__</code>,
      <code>__sizeof__</code>,
      <code>__str__</code>,
      <code>__subclasshook__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== CLASS METHODS ==================== -->
<a name="section-ClassMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Class Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-ClassMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="googleapiclient.http.MediaUpload-class.html">MediaUpload</a></code></b>:
      <code><a href="googleapiclient.http.MediaUpload-class.html#new_from_json">new_from_json</a></code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== STATIC METHODS ==================== -->
<a name="section-StaticMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Static Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-StaticMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="from_json"></a><span class="summary-sig-name">from_json</span>(<span class="summary-sig-arg">s</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="googleapiclient.http-pysrc.html#MediaFileUpload.from_json">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== PROPERTIES ==================== -->
<a name="section-Properties"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Properties</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Properties"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__class__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">filename</span>,
        <span class="sig-arg">mimetype</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">chunksize</span>=<span class="sig-default">DEFAULT_CHUNK_SIZE</span>,
        <span class="sig-arg">resumable</span>=<span class="sig-default">False</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#MediaFileUpload.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">
Constructor.

Args:
  filename: string, Name of the file.
  mimetype: string, Mime-type of the file. If None then a mime-type will be
    guessed from the file extension.
  chunksize: int, File will be uploaded in chunks of this many bytes. Only
    used if resumable=True. Pass in a value of -1 if the file is to be
    uploaded in a single chunk. Note that Google App Engine has a 5MB limit
    on request size, so you should never set your chunksize larger than 5MB,
    or to -1.
  resumable: bool, True if this is a resumable upload. False means upload
    in a single request.

</pre>
  <dl class="fields">
    <dt>Decorators:</dt>
    <dd><ul class="nomargin-top">
        <li><code>@util.positional(2)</code></li>
    </ul></dd>
    <dt>Overrides:
        object.__init__
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="to_json"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">to_json</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#MediaFileUpload.to_json">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">
Creating a JSON representation of an instance of MediaFileUpload.

Returns:
   string, a JSON representation of this instance, suitable to pass to
   from_json().

</pre>
  <dl class="fields">
    <dt>Overrides:
        <a href="googleapiclient.http.MediaUpload-class.html#to_json">MediaUpload.to_json</a>
    </dt>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="googleapiclient-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Fri Feb 19 16:00:25 2016
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
